import Love from "../love/love"
var love = new Love("gameover")

love.enter = function (result) {
  love.graphics.setDesignResolution(1600, 900)
  this.result = "你跑了"+result+"公里"
  this.titleW = love.loader.data.font50.getWidth(this.result)
  this.anykeyW = love.loader.data.font50.getWidth("【轻触屏幕继续】")
  this.bg = love.loader.getRes("bg")
  this.c = { r: 255, b: 255, g: 255, a: 0 }
}
love.update = function (dt) {
}
var d = 1

love.draw = function () {
  var bgDim = this.bg.getDimentions()
  var scDim = love.graphics.getDimensions()
  love.graphics.setColor("#FFFFFF")
  love.graphics.draw(this.bg, 0, 0, 0, 1600 / bgDim.w, 900 / bgDim.h)
  love.graphics.setColor("red")
  love.graphics.setFont(love.loader.data.font50)
  love.graphics.print(this.result, 800 - love.titleW / 2, 400)
  this.c.a = this.c.a + d
  if (this.c.a >=  255 || this.c.a <= 0) {
    d = -d
  }
  love.graphics.setColor(this.c)
  love.graphics.print("【轻触屏幕继续】", 800 - love.anykeyW / 2, 550)
}
love.touch.onTouch = function (touches) {
  love.switch("main")
}

export default love